package com.example.springblog.config;

import com.example.springblog.common.Constants;
import com.example.springblog.model.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ResponseBody
@ControllerAdvice
public class ErrorAdvice {
    @ExceptionHandler
    public Result errorHandler(Exception e){
        Result result = new Result<>();
        result.setErrorMsg("内部错误,请联系管理员");
        result.setCode(Constants.RESULT_FAIL);
        return result;
    }
}
